package com.ten.course.controller;

import com.ten.common.core.entity.EduVideo;
import com.ten.common.core.vo.Result;
import com.ten.course.service.CourseVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：张成（3092211427@qq.com）
 * @date ：Created in 2022/12/22 11:52
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/core/video")
@Api(tags = "课程视频接口类")
public class CourseVideoController {
    @Autowired
    private CourseVideoService courseVideoService;

    /**
     * 根据chapterId查询出章节下的视频
     * @param chapterId
     * @return
     */
    @ApiOperation(value = "根据chapterId查询出章节下的视频")
    @GetMapping("findAllVideo/{chapterId}")
    public Result<List<EduVideo>> findAllVideo(@PathVariable String chapterId){
        return courseVideoService.findAllVideo(chapterId);
    }

    /**
     * 添加视频表中的信息
     * @param eduVideo
     * @return
     */
    @ApiOperation(value = "添加视频表中的信息")
    @PutMapping("insertVideo")
    public Result insertVideo(@RequestBody EduVideo eduVideo){
        return courseVideoService.insertVideo(eduVideo);
    }
    /**
     * 修改视频表中的信息
     * @param eduVideo
     * @return
     */
    @ApiOperation(value = "修改视频表中的信息")
    @PostMapping("updateVideo")
    public Result updateVideo(@RequestBody EduVideo eduVideo){
        return courseVideoService.updateVideo(eduVideo);
    }

    /**
     * 删除视频表中的信息
     * @param id
     * @param sort
     * @param chapterId
     * @return
     */
    @ApiOperation(value = "删除视频表中的信息")
    @DeleteMapping("deleteById/{id}/{sort}/{chapterId}")
    public Result deleteById(@PathVariable String id,
                             @PathVariable Integer sort,
                             @PathVariable String chapterId){
        return courseVideoService.deleteById(id,sort,chapterId);
    }

    /**
     * 根据课程id查询出所有章节的视频信息
     * @param courseId
     * @return
     */
    @ApiOperation(value = "根据课程id查询出所有章节的视频")
    @PostMapping("queryAllVideoByCourseId/{courseId}")
    public Result<List<EduVideo>> queryAllVideoByCourseId(@PathVariable String courseId){
        return courseVideoService.queryAllVideoByCourseId(courseId);
    }

}